package chc

type (
	fn func(string) string

	Fielder interface {
		String() string
		FieldType() int
		SetRaw(interface{}) error
		RawValue() interface{}
	}
	// Params stores the Params
	Params map[string]interface{}

	// ParamsList stores paramslist
	ParamsList []interface{}

	argInt []int
)

const (
	odCascade             = "cascade"
	odSetNULL             = "set_null"
	odSetDefault          = "set_default"
	odDoNothing           = "do_nothing"
	defaultStructTagName  = "orm"
	defaultStructTagDelim = ";"
)

const (
	TypeBooleanField = 1 << iota
	TypeVarCharField
	TypeCharField
	TypeTextField
	TypeTimeField
	TypeDateField
	TypeDateTimeField
	TypeBitField
	TypeSmallIntegerField
	TypeIntegerField
	TypeBigIntegerField
	TypePositiveBitField
	TypePositiveSmallIntegerField
	TypePositiveIntegerField
	TypePositiveBigIntegerField
	TypeFloatField
	TypeDecimalField
	TypeJSONField
	TypeJsonbField
	RelForeignKey
	RelOneToOne
	RelManyToMany
	RelReverseOne
	RelReverseMany
)

const (
	IsIntegerField         = ^-TypePositiveBigIntegerField >> 6 << 7
	IsPositiveIntegerField = ^-TypePositiveBigIntegerField >> 10 << 11
	IsRelField             = ^-RelReverseMany >> 18 << 19
	IsFieldType            = ^-RelReverseMany<<1 + 1
)

const (
	formatTime      = "15:04:05"
	formatDate      = "2006-01-02"
	formatDateTime  = "2006-01-02 15:04:05"
	formatTimestamp = "2006-01-02 15:04:05.000"
)

const (
	ExprSep = "__"
)

const (
	TableQuote = "`"
	FieldQuote = "`"
)

const (
	MaxLimit uint64 = 18446744073709551615
)

var (
	supportTag = map[string]int{
		"-":            1,
		"null":         1,
		"index":        1,
		"unique":       1,
		"pk":           1,
		"auto":         1,
		"auto_now":     1,
		"auto_now_add": 1,
		"size":         2,
		"column":       2,
		"default":      2,
		"rel":          2,
		"reverse":      2,
		"rel_table":    2,
		"rel_through":  2,
		"digits":       2,
		"decimals":     2,
		"on_delete":    2,
		"type":         2,
		"description":  2,
	}

	operators = map[string]bool{
		"exact":     true,
		"iexact":    true,
		"contains":  true,
		"icontains": true,
		// "regex":       true,
		// "iregex":      true,
		"gt":          true,
		"gte":         true,
		"lt":          true,
		"lte":         true,
		"eq":          true,
		"nq":          true,
		"ne":          true,
		"startswith":  true,
		"endswith":    true,
		"istartswith": true,
		"iendswith":   true,
		"in":          true,
		"between":     true,
		// "year":        true,
		// "month":       true,
		// "day":         true,
		// "week_day":    true,
		"isnull": true,
		// "search":      true,
	}

	chOperators = map[string]string{
		"exact":     "= ?",
		"iexact":    "LIKE ?",
		"contains":  "LIKE BINARY ?",
		"icontains": "LIKE ?",
		// "regex":       "REGEXP BINARY ?",
		// "iregex":      "REGEXP ?",
		"gt":          "> ?",
		"gte":         ">= ?",
		"lt":          "< ?",
		"lte":         "<= ?",
		"eq":          "= ?",
		"ne":          "!= ?",
		"startswith":  "LIKE BINARY ?",
		"endswith":    "LIKE BINARY ?",
		"istartswith": "LIKE ?",
		"iendswith":   "LIKE ?",
	}
)
